package com.java01.regex.matcher;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Get all backreferences
 * Gets the input subsequence captured by the given group during the previous match operation. 
 */
public class Matcher1 {

	public static void main(String[] args) {
		String line = "Welcome to www.java01.com";
		
		Pattern pattern = Pattern.compile("^(.+)\\s+(.+)\\s+(.+)$");
		Matcher matcher =pattern.matcher(line);
		if(matcher.matches()){
			System.out.println("group(0)="+matcher.group(0));
			System.out.println("group(1)="+matcher.group(1));
			System.out.println("group(2)="+matcher.group(2));
			System.out.println("group(3)="+matcher.group(3));
		}else{
			System.out.println("X");
		}
	}
}
